﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.MacModel
{
    public partial class OJobAdd : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.新增 };
            }
        }

        protected override string DWZRef
        {
            get { return "OJobList"; }
        }
        

        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "addjob")
            {
                addmenu();
                
            }
        }

        protected void addmenu()
        {
            OJobInfo obj = Request.SerializableObject<OJobInfo>();
           // obj.UserType = 1;
           
            int r=OJobController.Add(obj);

            this.AddLog(Permission.新增, null, obj);
            if (r == -1)
            {
                ErrorJson(string.Format("添加失败,机号[{0}]已添加过,无需再一次添加,你可以对机号为{0}进行修改,请使用修改功能",obj.SerialNumber), this.DWZRef);
                
            }
            else if (r > 0)
            {
                SuccessJson("添加成功", this.DWZRef);
            }
            else
            {
                ErrorJson("添加失败", this.DWZRef);
            }
        }
    }
}